package com.shiguiwu.springmybatis.designpattern.dutychain.controller;

import cn.hutool.core.date.DateUtil;
import com.shiguiwu.springmybatis.designpattern.dutychain.AuthInfo;
import com.shiguiwu.springmybatis.designpattern.dutychain.service.AuthService;

import java.util.Date;

/**
 * @description:
 * @author: stone
 * @date: Created by 2021/9/2 10:05
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.dutychain.controller
 */
public class AuthController {

    public AuthInfo doAuth(String orderId, Date authDate) {
        //三级审批
        Date date = AuthService.queryAuthInfo("100011", orderId);
        if (null == date) {
            return new AuthInfo("10000", "单号：", orderId, "状态：待三级审批负责人", "王工");
        }

        //二级审批
        if (date.after(DateUtil.parse("2020-06-01 00:00:00", "yyyy-MM-dd hh:mm:ss"))
                && date.before(DateUtil.parse("2020-06-25 23:59:59", "yyyy-MM-dd hh:mm:ss"))) {
            return new AuthInfo("10001", "单号：", orderId, "状态：待二级审批负责人", "张经理");

        }
        //一级审批
        if (date.after(DateUtil.parse("2020-06-11 00:00:00", "yyyy-MM-dd hh:mm:ss"))
                && date.before(DateUtil.parse("2020-06-20 23:59:59", "yyyy-MM-dd hh:mm:ss"))) {
            return new AuthInfo("10002", "单号：", orderId, "状态：待一级审批负责人", "段总");

        }
        return new AuthInfo("10000", "单号：", orderId, "状态：待三级审批负责人", "王工");
    }
}
